﻿//-----------------------------------------------------------------------
// <copyright file="StringExtentions.cs" company="Forebrain Technology, LLC">
//
// Copyright (c) Forebrain Technology, LLC. All rights reserved.
// 
// This source code is released under the Microsoft Public License (Ms-PL).
//
// </copyright>
//-----------------------------------------------------------------------
namespace PivotCollectionTools.Data
{
    /// <summary>
    /// Strig extentions adding functionality missing in the system namespace.
    /// </summary>
    internal static class StringExtentions
    {
        /// <summary>
        /// Determines whether the specified test value has numbers.
        /// </summary>
        /// <param name="testValue">The test value.</param>
        /// <returns>
        /// <c>true</c> if the specified test value has numbers; otherwise, <c>false</c>.
        /// </returns>
        public static bool HasNumbers(this string testValue)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(testValue, @"\d+");
        }

        /// <summary>
        /// Get a substring to the right of the starting position of the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="startPosition">The starting positio in the string.</param>
        /// <returns>The substring to the right of the start position.</returns>
        public static string RightString(this string value, int startPosition)
        {
            return value.Substring(value.Length - startPosition, startPosition);
        }
    }
}
